<?php
/* 
 *赠品 规则管理
 */
class Over_gift_ruleAction extends CommonAction {
    public function _filter(&$map) {
        $key = trim($_REQUEST['keywords']);
        if(!empty($key)) {
            $map['Common_product.name'] = array('like',"%".$key."%");//url
            $map['out_number'] = array('like',"%".$key."%");//url
            
            $map['_logic'] = "or";
        }
    }

    public function index()
    {
        parent::index('Over_gift_rule');
    }

    public function _before_add()
    {
        $this->assign('brands',M('Brand')->where('status=1')->findAll());
    }

    public function _before_insert()
    {
        $_POST['brand_id'] = serialize($_POST['brand_id']);
    }

     public function _before_update()
    {
        $_POST['brand_id'] = serialize($_POST['brand_id']);
    }

    public function _before_edit()
    {
        $brands = M('Brand')->where('status=1')->getField('id,name');
        $this->assign('brands', $brands );
        $brand_ids = M('Over_gift_rule')->where('id = '.$_GET['id'])->getField('brand_id');

        $this->assign('brand_ids',unserialize($brand_ids)  );
    }



}
?>
